﻿using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
namespace Common.UGUI.View
{
	public class UDropdown : UBase
	{
		Dropdown _dropdown;
		public Action<int> DoValueChanged;
		public UDropdown(GameObject go)
		{
			_dropdown = go.GetComponent<Dropdown>();
            //_dropdown.onValueChanged.AddListener(DoValueChanged);
            _dropdown.onValueChanged.AddListener(delegate (int i){ DoValueChanged(i); });
		}

        void OnValueChanged(int index)
        {

        }
        /// <summary>
        /// 入门的增删查改
        /// </summary>
        /// <param name="item"></param>
        public void Add(string item)
		{
			_dropdown.options.Add(new Dropdown.OptionData(item));
		}

		/// <summary>
		/// 多一个方法
		/// </summary>
		/// <param name="ee"></param>
		public void AddEnum(Array ee)
		{
			foreach (var e in ee)
			{
				Add(e.ToString());
			}
		}

		/////////////////////// xi下面方法，只是展示好玩，不能直接用的，还要调整
		/// <summary>
		/// 再一个方法重载
		/// </summary>
		/// <param name="ee"></param>
		/// <param name="t"></param>
		public void AddEnum(Enum ee, Type t)
		{
			AddEnum(Enum.GetValues(t));
		}
		/// <summary>
		/// 泛型
		/// </summary>
		/// <typeparam name="T"></typeparam>
		/// <param name="ee"></param>
		public void AddEnum<T>(Enum ee)
		{
			AddEnum(Enum.GetValues(typeof(T)));
		}
	}
}
